package com.travel.util;

import java.util.List;

/**
 * 分页工具类
 * @author Administrator
 *
 * @param <T>
 */
public class PageInfo<T> { // <T>表示泛型
	
	private List<T> data;     // 当前页的数据
	private Integer pageNum;  // 页码
	private Integer pageSize; // 每页显示的记录数
	private Integer total;    // 总记录数
	private Integer pages;    // 总页数
	
	public PageInfo(List<T> data, Integer pageNum, Integer pageSize, Integer total) {
		super();
		this.data = data;
		this.pageNum = pageNum;
		this.pageSize = pageSize;
		this.total = total;
		// 直接通过总记录数和每页记录数换算出总页数
		this.pages = total % pageSize == 0 ? total / pageSize : total / pageSize + 1 ;
	}
	public PageInfo() {
		super();
	}
	public List<T> getData() {
		return data;
	}
	public void setData(List<T> data) {
		this.data = data;
	}
	public Integer getPageNum() {
		return pageNum;
	}
	public void setPageNum(Integer pageNum) {
		this.pageNum = pageNum;
	}
	public Integer getPageSize() {
		return pageSize;
	}
	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}
	public Integer getTotal() {
		return total;
	}
	public void setTotal(Integer total) {
		this.total = total;
	}
	public Integer getPages() {
		return pages;
	}
	public void setPages(Integer pages) {
		this.pages = pages;
	}
	
	
	
}
